import type { App } from "vue";
import {
  createRouter,
  createWebHistory,
  type RouteRecordRaw,
} from "vue-router";
import Wfs from "../views/ol/wfs.vue";
import Wms from "../views/ol/wms.vue";
import Wmts from "../views/ol/wmts.vue";
import Baidu from "../views/ol/baidu.vue";
import Gaode from "../views/ol/gaode.vue";
import Supermap from "../views/ol/supermap.vue";
import Tiandt from "../views/ol/tiandt.vue";
import vectorsource from "../views/ol/vectorsource.vue";

import formDemo from "../views/element/formDemo.vue";
import tableDemo from "../views/element/tableDemo.vue";

let routes: RouteRecordRaw[] = [
  {
    path: "/ol",
    name: "ol",
    meta: {
      title: "ol demo",
    },
    children: [
      {
        path: "vectorsource",
        name: "vectorsource",
        component: vectorsource,
        meta: {
          title: "矢量数据源",
        },
      },
      {
        path: "wfs",
        name: "wfs",
        component: Wfs,
        meta: {
          title: "wfs数据源",
        },
      },
      {
        path: "wms",
        name: "wms",
        component: Wms,
        meta: {
          title: "wms数据源",
        },
      },
      {
        path: "wmts",
        name: "wmts",
        component: Wmts,
        meta: {
          title: "wmts数据源",
        },
      },
      {
        path: "baidu",
        name: "baidu",
        component: Baidu,
        meta: {
          title: "百度数据源",
        },
      },
      {
        path: "gaode",
        name: "gaode",
        component: Gaode,
        meta: {
          title: "高度数据源",
        },
      },
      {
        path: "tiandt",
        name: "tiandt",
        component: Tiandt,
        meta: {
          title: "天地图数据源",
        },
      },
      {
        path: "supermap",
        name: "supermap",
        component: Supermap,
        meta: {
          title: "超图数据源",
        },
      },
    ],
  },
  {
    path: "/cesium",
    name: "cesium",
    meta: {
      title: "cesium demo",
    },
    children: [
      {
        path: "wfs",
        name: "wfs",
        component: Wfs,
        meta: {
          title: "wfs数据源",
        },
      },
      {
        path: "wms",
        name: "wms",
        component: Wms,
        meta: {
          title: "wms数据源",
        },
      },
      {
        path: "baidu",
        name: "baidu",
        component: Baidu,
        meta: {
          title: "百度数据源",
        },
      },
      {
        path: "gaode",
        name: "gaode",
        component: Gaode,
        meta: {
          title: "高度数据源",
        },
      },
      {
        path: "tiandt",
        name: "tiandt",
        component: Tiandt,
        meta: {
          title: "天地图数据源",
        },
      },
      {
        path: "supermap",
        name: "supermap",
        component: Supermap,
        meta: {
          title: "超图数据源",
        },
      },
    ],
  },
  {
    path: "/element",
    name: "element",
    meta: {
      title: "element demo",
    },
    children: [
      {
        path: "formDemo",
        name: "formDemo",
        component: formDemo,
        meta: {
          title: "表单",
        },
      },
      {
        path: "tableDemo",
        name: "tableDemo",
        component: tableDemo,
        meta: {
          title: "表格",
        },
      }
    ]
  }
];
function setupRouter(app: App) {
  const router = createRouter({
    history: createWebHistory(),
    routes: routes,
  });
  app.use(router);
}

export {  setupRouter , routes }